﻿using ProtoBuf;
using System.Collections.Generic;

namespace ToyChat.BuiltinModules
{
    /// <summary>
    /// This message is used to "control" channels
    /// </summary>
    [ProtoContract(Name = "Core.ChannelControlMessage")]
    public class ChannelControlMessage
    {
        /// <summary>
        /// Gets or Sets the new channel name of the channel
        /// </summary>
        [ProtoMember(1, IsRequired = false)]
        public string ChannelName { get; set; }

        /// <summary>
        /// Gets or Sets the new MotD of the channel
        /// </summary>
        [ProtoMember(2, IsRequired = false)]
        public string MotD { get; set; }

        /// <summary>
        /// Gets or Sets the new password of the channel
        /// <para/>
        /// string.empty specifies NO password
        /// </summary>
        [ProtoMember(3, IsRequired = true)]
        public string Password { get; set; }

        /// <summary>
        /// Gets or Sets the new default permissions of the channel
        /// </summary>
        [ProtoMember(4, IsRequired = false)]
        public ChannelPermissionFlags? DefaultPermissions { get; set; }

        /// <summary>
        /// Gets or Sets the new user permissions of the channel
        /// </summary>
        [ProtoMember(5, IsRequired = false)]
        public Dictionary<string, ChannelPermissionFlags> UserPermissions { get; set; }

        /// <summary>
        /// Gets or Sets the new group permissions of the channel
        /// </summary>
        [ProtoMember(6, IsRequired = false)]
        public Dictionary<string, ChannelPermissionFlags> GroupPermissions { get; set; }

        /// <summary>
        /// Gets or Sets a value indicating whether or not the channel should be hidden from the channel list
        /// </summary>
        [ProtoMember(7, IsRequired = false)]
        public bool? IsHidden { get; set; }

        /// <summary>
        /// Gets or Sets a value indicating the control mode of this message (<see cref="ControlMode"/>)
        /// </summary>
        [ProtoMember(8, IsRequired = true)]
        public ControlMode Mode { get; set; }
    }

    /// <summary>
    /// This enum specifies possible modes of operation for a <see cref="ChannelControlMessage"/>
    /// </summary>
    public enum ControlMode : byte
    {
        /// <summary>
        /// Indicates that the channel is to be deleted (if permitted, and found)
        /// </summary>
        Delete = 0x01,

        /// <summary>
        /// Indicates that the channel is to be modified (if permitted, and found)
        /// </summary>
        Modify = 0x02,

        /// <summary>
        /// Indicates that the channel is to be created (if permitted, and no channel with the specified channel name exists)
        /// </summary>
        Create = 0x03,
    }
}